package com.shnu.work.service.impl;

import com.shnu.work.entity.SystemInformationEntity;
import com.shnu.work.repository.SystemInformationRepository;
import com.shnu.work.service.ISystemInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * @author Shinomiya Kaguya
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SystemInformationServiceImpl implements ISystemInformationService {
    @Autowired
    private SystemInformationRepository systemInformationRepository;

    @Override
    public Optional<SystemInformationEntity> getSysInfoById(Long id) {
        return systemInformationRepository.findById(id);
    }

    @Override
    public List<SystemInformationEntity> listAllUndeletedSysInfo() {
        return systemInformationRepository.listAllUndeletedSysInfo();
    }

    @Override
    public SystemInformationEntity saveNewSysInfo(SystemInformationEntity sysInfo) {
        return systemInformationRepository.save(sysInfo);
    }

    @Override
    public Integer clearAllAvailableStatus() {
        return systemInformationRepository.clearAllAvailableStatus();
    }

    @Override
    public Integer updateAvailableStatusById(Long id) {
        return systemInformationRepository.updateAvailableStatusById(id);
    }

    @Override
    public Integer removeSysInfoById(Long id) {
        return systemInformationRepository.removeSysInfoById(id);
    }
}
